package main

import "log"

type Rect struct  {
	x,y float64
	width,height float64
}

func (rect *Rect) Area() float64  {
	return rect.width * rect.height
}

type Base struct  {
	Name string
	*log.Logger
}

func (base *Base) Foo()  {
	log.Println("base Foo")
}

func (base *Base) bar()  {
	log.Println("base bar")
}

type Foo struct  {
	*Base
	Id string
}

func (foo *Foo) Foo()  {
	foo.Base.Foo()
	log.Println("foo foo->")
}

//interface extends

type IReader interface {
	Read(bs []byte)(n int,err error)
}

type IWriteer interface {
	Write(buf []byte)(n int,err error)
}

type File struct  {

}

func (read *File) Read(buf []byte)(n int,err error)  {
	println("read byte",buf)
	return 0 , nil
}

func (write *File) Write(buf []byte)(n int,err error)  {
	println("write byte",buf)
	return 0 , nil
}

func main() {
	var rect = Rect{0.1,1.2,1.2,2.3}
	println("area is ",int(rect.Area()))
	var rect1 = new(Rect)
	var rect2 = &Rect{}
	var rect3 = &Rect{width:2.3,height:3.4}
	var rect4 = &Rect{0.1,1.2,1.2,2.3}

	println(rect1.x,rect1.width)
	println(rect2)
	println(rect3)
	println(rect4)

	var base = Base{}

	base.Foo()
	base.bar()

	var foo = &Foo{}
	foo.Foo()
	foo.bar()

	//println(foo.Base == base)
	//println(&foo.Base)
	//println(&base==&foo.Base)

	var read IReader = new(File) //&File{}
	var write IWriteer = &File{}

	read.Read([]byte{56,57})
	write.Write([]byte{33,43})
}
